#ifndef SNAKEGAME_H
#define SNAKEGAME_H

#include <vector>
#include <QPoint>

enum class Direction { Up, Down, Left, Right, None };
enum class FoodType { Yellow, Blue, Red };

struct Food
{
    QPoint position;
    FoodType type;
};

class SnakeGame
{
public:
    SnakeGame();

    void initialize();
    void update();
    bool isGameOver() const;
    int getScore() const;

    void setDirection(Direction newDirection);
    Direction getDirection() const;

    const std::vector<QPoint>& getSnake() const;
    const Food& getFood() const;

private:
    std::vector<QPoint> snake;
    Direction currentDirection;
    Direction nextDirection;
    Food food;
    bool gameOver;
    int score;
    int gridWidth;
    int gridHeight;

    void generateFood();
    bool checkCollision() const;
    void moveSnake();
    bool isOutOfBounds(const QPoint &point) const;
    bool isSnakeBody(const QPoint &point, bool excludeHead = false) const;
    FoodType randomFoodType() const;
};

#endif
